from peewee import *

db = MySQLDatabase('test',
                   **{'charset': 'utf8', 'sql_mode': 'PIPES_AS_CONCAT', 'use_unicode': True, 'user': 'root',
                      'password': 'root'})


class UnknownField(object):
    def __init__(self, *_, **__): pass


class BaseModel(Model):
    class Meta:
        database = db


class User(BaseModel):
    age = IntegerField(null=True)
    birthday = DateTimeField(null=True)
    name = CharField(null=True)

    class Meta:
        table_name = 'user'


# 批量修改
u1 = User.get(id=1)
u2 = User.get(id=2)
u3 = User.get(id=3)

u1.name = '测试姓名1'
u2.name = '测试姓名2'
u3.name = '测试姓名3'

User.bulk_update([u1, u2, u3], fields=[User.name])